package com.cjkj.agent.controller;

import com.cjkj.agent.domain.vo.AgentAreaVo;
import com.cjkj.agent.service.ITAgentAreaInfoService;
import com.cjkj.common.annotation.RepeatSubmit;
import com.cjkj.common.core.controller.BaseController;
import com.cjkj.common.core.domain.AjaxResult;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 代理商代理区域信息Controller
 * 
 * @author cjkj
 * @date 2025-10-11
 */
@RestController
@RequestMapping("/agent/area")
public class TAgentAreaInfoController extends BaseController
{
    @Resource
    private ITAgentAreaInfoService tAgentAreaInfoService;

    /**
     * 查询代理商代理区域
     */
    @PreAuthorize("@ss.hasPermi('agent:area:query')")
    @GetMapping("/list/{agentId}")
    public AjaxResult list(@PathVariable("agentId") String agentId)
    {
        return AjaxResult.success(tAgentAreaInfoService.selectAgentAreaData(agentId));
    }

    /**
     * 设置代理商代理区域
     */
    @PreAuthorize("@ss.hasPermi('agent:area:set')")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁！")
    @PostMapping("/set/{agentId}")
    public AjaxResult list(@PathVariable("agentId") String agentId, @RequestBody List<AgentAreaVo> areaList)
    {
        return toAjax(tAgentAreaInfoService.setAgentAreaInfo(agentId, areaList));
    }

}
